/**
 * 				ClientManager.java
 *				------------
 *		
 *   Author:	bin04017@gmail.com
 *	 Created:	13.12.2006
 *	 Project:	MP3-Sync (Mochito)
 *	 Package:	mochito.clientClasses
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 */
package mochito.clientClasses;

import java.rmi.RemoteException;
import java.util.Set;

import mochito.clientClasses.clientRMI.ClientRMI;
import mochito.clientClasses.clientTimer.ClientTimer;
import mochito.dataClasses.musicItem.MusicItem;

/**
 * @author bin04017
 * 
 */
public class ClientManager {

	private String host = null;
	
	private ClientRMI clientRMI = null;

	private ClientTimer clientTimer = null;

	public ClientManager(String host) throws Exception {
		this.host = host;
		init();
	}
	private void init() throws Exception{
		if (clientRMI == null) {
			clientRMI = new ClientRMI(host);
		}
		if (clientTimer == null) {
			clientTimer = new ClientTimer();
		}
	}
	public Set<String> getMusicItems() throws RemoteException{
		return this.getClientRMI().getMusicItems();
	}
	public MusicItem getMusicItem(String name, String dir) throws Exception{
		return this.getClientRMI().getMusicItem(name, dir);
	}
	public void setTimerForMusicItem(MusicItem item){
		this.getClientTimer().addMusicItem(item);
	}
	public void setTimerForMusicItem(String name, String dir) throws Exception{
		this.getClientTimer().addMusicItem(this.getMusicItem(name, dir));
	}
	public void startTimer(){
		this.getClientTimer().start();
	}
	public void stopTimer(){
		this.getClientTimer().stop();
	}
	protected ClientRMI getClientRMI() {
		return clientRMI;
	}
	protected void setClientRMI(ClientRMI clientRMI) {
		this.clientRMI = clientRMI;
	}
	protected ClientTimer getClientTimer() {
		return clientTimer;
	}
	protected void setClientTimer(ClientTimer clientTimer) {
		this.clientTimer = clientTimer;
	}
	public String getHost() {
		return host;
	}
}
